package module.main.view.mainInterface
{
	
	import code.utils.MaterialUtil;
	import code.ui.SimpleToolTips;
	
	import com.darwin.darwinDll.Dll;
	import com.darwin.darwinUI.containers.ContainerBase;
	import com.darwin.darwinUI.core.UIComponent;
	import com.darwin.darwinUI.manager.UIManager;
	
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	import module.main.view.ResourceConst;

	/**
	 *玩家头像面板 
	 * @author jichang
	 * 
	 */
	public class PlayHeadPlane extends ContainerBase
	{
		/**
		 *玩家头像背景 
		 */		
		private var playerExamine:Sprite;
		/**
		 * 玩家相片
		 */
		private var playerPhoto:Sprite;
		/**
		 *玩家公会称号ICON 
		 */		
		private var playerTitle:Sprite;
		/** 
		 * 玩家姓名
		 */		
		private var playerName:Sprite;
		/**
		 *玩家公会名称 
		 */		
		private var playerSociatyName:Sprite;
		private var uicommand:UIComponent;
		public function PlayHeadPlane()
		{
			uicommand = new UIComponent();
			playerExamine 	  = MaterialUtil.getPreloadMaterial("main",ResourceConst.PLAYER_HEAD_EXAMINE) as Sprite;
			playerPhoto 	  = MaterialUtil.getPreloadMaterial("main",ResourceConst.PLAYER_HEAD_PHOTO) as Sprite;
		//	playerTitle	      = MaterialUtil.getPreloadMaterial("center",ResourceConst.PLAYER_HEAD_TITLE_ICON) as Sprite;
			playerName 		  = MaterialUtil.getPreloadMaterial("main",ResourceConst.PLAYER_NAME) as Sprite;
			playerSociatyName = MaterialUtil.getPreloadMaterial("main",ResourceConst.PLAYER_SOCIATY_NAME) as Sprite;
			
			this.addItem(uicommand);
			this.width = playerExamine.width;
			this.height = playerExamine.height;
			
			uicommand.width = playerExamine.width;
			uicommand.height = playerExamine.height;
			
			init();
			
//			playerTitle.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler);
			

		}
		
		private function mouseMoveHandler(e:MouseEvent):void{
			UIManager.getToolTipManager().showTips(SimpleToolTips,e.target,"玩家称号<br>");
		}
		
		private function init():void
		{
			setPlayerExamine();
			setPlayerPhoto();
			setPlayerTitle();
			setPlayerName();
			setPlayerSociatyName();
		}
		private function setPlayerExamine():void
		{
			playerExamine.x = 0;
			playerExamine.y = 0;
			uicommand.addChild(playerExamine);
		}
		private function setPlayerPhoto():void
		{
			playerPhoto.x = 14;
			playerPhoto.y = 10;
			uicommand.addChild(playerPhoto);
		}
		private function setPlayerTitle():void
		{
		/*	playerTitle.x = playerPhoto.x / 2 - 2;
			playerTitle.y = playerPhoto.y + playerPhoto.height - 3*playerTitle.height/4 + 4;
			uicommand.addChild(playerTitle);*/
		}
		private function setPlayerName():void
		{
			playerName.x = playerPhoto.x;
			playerName.y = (playerExamine.height - playerPhoto.y - playerPhoto.height - playerName.height)/2
						 + playerPhoto.y + playerPhoto.height - 3;
			uicommand.addChild(playerName);
		}
		private function setPlayerSociatyName():void
		{
			playerSociatyName.x = playerPhoto.x;
			playerSociatyName.y = playerPhoto.y - playerSociatyName.height / 2 - 5;
			uicommand.addChild(playerSociatyName);
		}
	}
}